package com.suray.basic.wcs.plc.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.suray.basic.wcs.plc.entity.PlcLogDB;
import com.suray.basic.wcs.plc.mapper.PlcLogMapper;
import com.suray.basic.wcs.plc.service.IPlcLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Arrays;
import java.util.Date;
import java.util.List;

@Service
public class PlcLogServiceImpl extends ServiceImpl<PlcLogMapper, PlcLogDB> implements IPlcLogService {
    @Autowired
    private PlcLogMapper plcLogMapper;

    @Override
    public List<PlcLogDB> getPlcLogs(PlcLogDB plcLogdb) {
        return plcLogMapper.getPlcLogs(plcLogdb);
    }

    @Override
    public boolean setInterfaceLog(PlcLogDB plcLogdb) {
        return this.save(plcLogdb);
    }

    @Override
    public int deletePlcLogByIds(Long[] plcLogIds) {
        return plcLogMapper.deleteBatchIds(Arrays.asList(plcLogIds));
    }

    @Override
    public void cleanPlcLog() {
        plcLogMapper.cleanPlcLog();
    }

    @Override
    public void deletePlcLog(Integer days) {
        plcLogMapper.deleteThreeDaysPlcLog(days,new Date());
    }

}
